<?php if($this->res):?>

<?php /*if ( in_array($this->city['id'], array(1,2,33,41,46,47,50,92,70,75,79,82,84,96,106,110,123)) ):?>
	<?php $city_alias = $this->placeholder('city_alias')->getValue();?>
	<a rel="nofollow" href="/action/chiara2/<?=$this->city['alias']?>" style='display: block; position: absolute; top: 20px; right: 20px;'>
		<img alt="" src="/site/theme/action/chiara2/img/banner.png">
	</a>	
<?php endif;*/?>

<br/>
<div class="wherebuy">Где купить в городе&nbsp;<a href="/kupit/"><span><?php echo $this->city['label']?></span>&nbsp;<img src="/site/theme/img/arrow_orange_grey.gif" alt=""/></a></div>
<div class="custom-text-city">
	<div style='padding-left:30px;'>
	<?php echo $this->city['custom']?>
	</div>
</div>
<br class="clear"/>
<br/>
<?php $key=Zend_Registry::get('cnf')->yandexmapskey;?>
 
<script src="http://api-maps.yandex.ru/1.1/index.xml?key=<?=$key?>"	type="text/javascript"></script>
 
<script type="text/javascript">

function createMap(id,address,lng,lat){
	var map = new YMaps.Map(document.getElementById(id));
	map.setCenter(new YMaps.GeoPoint(lng-0.05,lat-0.005), 12, YMaps.MapType.MAP);
	
	map.addControl(new YMaps.Zoom());
	map.addControl(new YMaps.ToolBar());
	map.addControl(new YMaps.TypeControl());    
	var s = new YMaps.Style();
	s.iconStyle = new YMaps.IconStyle();
	s.iconStyle.offset = new YMaps.Point(-8,-27);
	s.iconStyle.href = "http://api-maps.yandex.ru/i/0.3/placemarks/pmlbm.png";
	s.iconStyle.size = new YMaps.Point(28,29);
	YMaps.Styles.add("wizard#lbmPoint", s);
	var placemark1 = new YMaps.Placemark(new YMaps.GeoPoint(lng,lat), {style: "wizard#lbmPoint", balloonOptions: {maxWidth: 300}});
	map.addOverlay(placemark1);
	placemark1.setBalloonContent(address);      
	placemark1.openBalloon();
	return true;
}
$(function(){
		$('#salon_list .data').css('display','none');

		$('#salon_list .slabel').live('click',function(){
			
			var liel=$(this).closest('li');
			var slabel=$(this);
			
			if(liel.hasClass('active')){
				liel.find('.data').slideUp();
				liel.removeClass('active');
			}else{
				$('#salon_list li').removeClass('active');
				$('#salon_list li:not(.active) .data').slideUp();
				liel.addClass('active');	
				liel.find('.data').slideDown(function(){
					if(liel.find('.data').css('display')=='block'){
						if(! slabel.hasClass('m')){
							slabel.addClass('m');
							var id=liel.find('.yanmap').attr('id');
							var address=liel.find('.slabel span').text();
							var lng=liel.find('.coord1').html();
							var lat=liel.find('.coord2').html();
							createMap(id,address,lng,lat);
						}
					}
				});


			}
			
			
			
			
			
			
			
					
			
			
				
			
			
			
			return false;
		});

		$('#salon_types a').live('click',function(){
				if(!$(this).closest('li').hasClass('active')){	
					$('#salon_types li').removeClass('active');
					$(this).closest('li').addClass('active');
					var type=$(this).attr('rel');
					if(type=='all'){
						$('#salon_list li').show();
					}else{
						$('#salon_list li.'+type).show();
						$('#salon_list li:not(.'+type+')').hide();
					}
				}
				return false;
		});


		if(window.location.hash){
			var hash=window.location.hash.replace('#','');
			$('#s'+hash).trigger('click');
		}

		

	});

</script>
<?php
$types=array();
foreach ($this->res as $salon){
	$types[$salon['type']][]=$salon['id'];
}
$firm=0;
if(isset($types['firm']))
$firm=sizeof($types['firm']);
$dealer=0;
if(isset($types['dealer']))
$dealer=sizeof($types['dealer']);


$total=sizeof($this->res);
?>
<ul id="salon_types" class="clearfix">
	<li>
		<span>Салоны:</span>
	</li>
	<li class="active">
		<a rel="all" href="#">Все</a>&nbsp;<?=$total ?>
	</li>
	<?php if($firm!=$total&&$firm!=0):?>
	<li>
		<a rel="firm" href="#">Фирменные</a>&nbsp;<?=$firm ?>
	</li>
	<?php endif;?>
	<?php if($dealer!=$total&&$dealer!=0):?>
	<li>
		<a rel="dealer" href="#">Дилерские</a>&nbsp;<?=$dealer ?>
	</li>
	<?php endif;?>
</ul>
<ol id="salon_list">
	<?php foreach ($this->res as $salon):?>
	<li class="<?=$salon['type']?>">
		<a name="salon-<?=$salon['id'] ?>"></a>
		<a id="ssalon-<?=$salon['id'] ?>" href="#" class="slabel"><span><?=$salon['label'];?></span></a>&nbsp;&nbsp;&nbsp;<span class="address"><?=$salon['address'] ?>&nbsp;&nbsp;&nbsp;Тел.:<?=$salon['phones'] ?></span>
		<div class="data clearfix">
			<b class="coord1" style="display:none"><?=$salon['shirota']?></b>
			<b class="coord2" style="display:none"><?=$salon['dolgota']?></b>
			<div id="map_<?=$salon['id'] ?>" class="yanmap"></div>
			<div class="iminfo">
				<div class="images">
					<?php $images=explode(',', trim($salon['images']));?>
						<?php if($images[0]):?>
						<div class="salon-scroll">
						<?php $size=sizeof($images);?>
							
						<?if($size>3):?>
						<a class="prev browse left"></a>
						<? endif;?>
						<div class="scrollable"><div class="items">
								<?php $images=array_chunk($images, 3)?>
								<?php foreach ($images as $page):?>
									<div>
									<?php foreach ($page as $id):?>
										<a class="popup" rel="salon_<?=$salon['id'] ?>" href="<?=$this->image_Helper($id)->crop()->resize(1280,1024)->getUrl();?>">
										<?=$this->image_Helper($id)->crop()->resize(155,115)->merge(ROOT_PATH.'/site/themes/default/img/loop.png', "right - 3", "bottom - 3")->render(array('class'=>'lazy'));?>
										</a>
									<?php endforeach;?>
									</div>
								<?php endforeach;?>
							</div></div>
						<?if($size>3):?>
							<a class="next browse right"></a>
						<?php endif;?>
							<br class="clear"/>
						</div>
					<?php endif;?>
				
						
				</div>
				
			</div>
			<br class="clear"/>
			<div class="info">
				<?if($salon['text']!=""):?>
				<div style='float: left; width: 527px;'>
					<?= $salon['text']?>
					<br class="clear"/>
				</div>
				<?endif;?>
				<div style='float: left; width: 300px; margin-left: 20px;'>
					<b>Режим работы:</b>&nbsp;<?=$salon['hour'] ?><br/>
					<b>Телефон:</b>&nbsp;<?=$salon['phones'] ?><br/>
					<b>Email:</b>&nbsp;<a href='mailto:<?=$salon['email'] ?>'><?=$salon['email'] ?></a><br/>
				</div>
				<br class="clear"/>
			</div>
		</div>
	</li>
	<?php endforeach;?>
</ol>

<?php endif;?>
